<template>
  <div class="goods">
    <div class="menu-wrapper">
      <ul>
        <li
          class="menu-item"
          v-for="(item, index) in goods"
          :key="index"
          :class="{ current: currentIndex === index }"
          @click="changeMenu(index)"
        >
          <supportico
            v-if="item.type > 0"
            :type="item.type"
            :size="1"
          ></supportico>
          <span class="text">{{ item.name }}</span>
        </li>
      </ul>
    </div>
    <div class="foods-wrapper">
      <li class="food-list">
        <h1 class="title">热销榜</h1>
        <ul>
          <li class="food-item">
            <div class="icon">
              <img src="" alt="" />
            </div>
            <div class="content">
              <h2 class="name">皮蛋瘦肉粥</h2>
              <p class="desc">咸粥</p>
              <div class="extra">
                <span class="count">月售200份</span>
                <span>好评98%</span>
              </div>
              <div class="price">
                <span class="now">￥10</span>
                <span class="old">￥12</span>
              </div>
            </div>
          </li>
        </ul>
      </li>
    </div>
  </div>
</template>

<script>
import { getGoods } from "@/api/index";
import supportico from "@/components/support-ico/support-ico";
export default {
  data() {
    return {
      currentIndex: 0,
      goods: [],
    };
  },
  components: {
    supportico,
  },
  created: function () {
    getGoods().then((res) => {
      console.log(res);
      this.goods = res;
    });
  },
  methods: {
    changeMenu(index) {
      this.currentIndex = index;
      console.log(index);
    },
  },
};
</script>

<style lang="less">
.goods {
  display: flex;
  position: absolute;
  top: 177px;
  bottom: 46px;
  width: 100%;
  overflow: hidden;
  .menu-wrapper {
    flex: 0 0 80px;
    width: 80px;
    background: #f3f5f7;
    .menu-item {
      display: flex;
      width: 60px;
      height: 54px;
      padding: 0 10px;
      text-align: center;
      justify-content: center;
      align-items: center;
      line-height: 14px;
      font-size: 12px;
    }
    .menu-item.current {
      background: #fff;
      font-weight: 700;
    }
  }
}
</style>